﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ActivePalInterop.Events
{
    #region Delegates declaration

	public delegate void ProgressBarEventHandler(object sender, ProgressBarEventArgs args);
    public delegate void ReadRowsPulseEventHandler(object sender, ProgressBarLablesEventArgs args);
    public delegate void ProgressControlEventHandler(object sender, ProgressControlEventArgs args);
    public delegate void MessageEventHandler(object sender, MessageEventArgs args);    
    public delegate void StaticMessageEventHandler(MessageEventArgs args);
    public delegate void IntValueEventHandler(object sender, IntValueEventArgs args);

	#endregion 

    /// <summary>
    /// Event args for storing int value
    /// </summary>
    public class IntValueEventArgs : EventArgs
    {
        public int IntValue { get; set; }

        public IntValueEventArgs(int value)
        {
            IntValue = value;
        }
    }
    /// <summary>
    /// Event args for handling progress bar values
    /// </summary>
    public class ProgressBarEventArgs : EventArgs
    {
        public int Min { get; set; }
        public int Max { get; set; }
        public int Current { get; set; }

        public ProgressBarEventArgs(int min, int max, int current)
        {
            Min = min;
            Max = max;
            Current = current;
        }
    }

    /// <summary>
    /// Event args for handling labels text in progress bar control
    /// </summary>
    public class ProgressBarLablesEventArgs : EventArgs
    {
        public string MajorLableText { get; set; }
        public string MinorLableText { get; set; }

        public ProgressBarLablesEventArgs(string majorText, string minorText)
        {
            MajorLableText = majorText;
            MinorLableText = minorText;
        }
    }

    /// <summary>
    /// Event args for handling pregress bar value and labels' text in progress bar control
    /// </summary>
    public class ProgressControlEventArgs : ProgressBarEventArgs
    {
        public string MajorLableText { get; set; }
        public string MinorLableText { get; set; }
        public int ProgressPercentage
        {
            get
            {
                int tmp = Convert.ToInt32(((double)Current / (double)Max ) * 100);
                if (tmp < 0)
                {
                    tmp = 0;
                }
                if (tmp > 100)
                {
                    tmp = 100;
                }

                return tmp;
            }
        }

        public ProgressControlEventArgs(int min, int max, int current, string majorText, string minorText)
            : base(min, max, current)
        {
            MajorLableText = majorText;
            MinorLableText = minorText;
        }
    }

    /// <summary>
    /// Event args for handling debug messages
    /// </summary>
    public class MessageEventArgs : EventArgs
    {
        public string Message { get; set; }

        public MessageEventArgs(string message)
        {
            Message = message;
        }
    }    
}
